const path = require('path')
const config = require('./webpack.common.js')
const merge = require('webpack-merge')

const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')

module.exports = merge(config, {
  devtool: 'source-map',
  devServer: {
    clientLogLevel: 'warning',
    hot: false,
    host: 'localhost',
    contentBase: false, // since we use CopyWebpackPlugin.
    port: 8000,
    open: false,
    watchOptions: {
      aggregateTimeout: 2000, // 浏览器延迟多少秒更新
      poll: 1000 // 每秒检查一次变动
    },
    quiet: true, // necessary for FriendlyErrorsPlugin
    compress: true, // 一切服务都启用gzip 压缩
    overlay: false ? { warnings: false, errors: true } : false
  },
  plugins: [
    new FriendlyErrorsPlugin({
      compilationSuccessInfo: {
        messages: ['Your application is running here: http://localhost:8000']
      },
      onErrors: function (severity, errors) {
        // 可以收听插件转换和优先级的错误
      }
    })
  ]
})
